<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" version="2.0">
	<jsp:directive.page contentType="text/html; charset=ISO-8859-1"
		pageEncoding="ISO-8859-1" session="false" />
	<jsp:output doctype-root-element="html"
		doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
		omit-xml-declaration="true" />
	<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Search Product</title>
<link href="/static/base.css" rel="stylesheet" type="text/css"></link>
</head>
<body>

	<c:choose>
		<c:when test="${userSession.type == 'User'}">
			<jsp:include page="/WEB-INF/jsp/page.header.jsp"></jsp:include>
		</c:when>
		<c:otherwise>
			<jsp:include page="/WEB-INF/jsp/admin/header.jsp"></jsp:include>
		</c:otherwise>
	</c:choose>
	<div style="text-align: left">

		<h1>Search Product</h1>

		<form id="myform" action="/service/product/search" method="GET">

			<table border="0" cellpadding="0" cellspacing="0">
				<tr valign="top">
					<td>Product's Category</td>
					<td>&#160;:&#160;</td>
					<td><input type="text" value="" name="prodCat" id="prodCat" /></td>
					<td>&#160;:&#160;</td>
					<td>&#160;:&#160;</td>
					<td>Product's Name</td>
					<td>&#160;:&#160;</td>
					<td><input type="text" value="" name="prodName" id="prodName" /></td>
				</tr>
				<tr valign="top">
					<td>Product's Price</td>
					<td>&#160;:&#160;</td>
					<td><SELECT name='prodPriceOperator' id="prodPriceOperator">
							<option value='eq'>=</option>
							<option value='lt'>&lt;</option>
							<option value='lte'>&lt;=</option>
							<option value='gt'>&gt;</option>
							<option value='gte'>&gt;=</option>
					</SELECT> <input type="text" value="" name="prodPrice" id="prodPrice" /></td>
					<td>&#160;:&#160;</td>
					<td>&#160;:&#160;</td>
					<td>Product's Rating</td>
					<td>&#160;:&#160;</td>
					<td><SELECT name='prodRating' id="prodRating">
							<option value='1'>1 - Very Poor</option>
							<option value='2'>2 - Poor</option>
							<option value='3'>3 - Neutral</option>
							<option value='4'>4 - Good</option>
							<option value='5'>5 - Very Good</option>
					</SELECT></td>
				</tr>
				<tr valign="top">
					<td>Posting Date (dd-MM-yyyy)</td>
					<td>&#160;:&#160;</td>
					<td><input type="text" value="" name="prodCreatedDate"
						id="prodCreatedDate" /></td>
					<td>&#160;:&#160;</td>
					<td>&#160;:&#160;</td>	
					<td>Seller's Name</td>
					<td>&#160;:&#160;</td>
					<td><input type="text" value="" name="sellerName"
						id="sellerName" /></td>
				</tr>
				<tr>
					<td colspan="8">&#160;</td>
				</tr>
				<tr align="left">
					<td colspan="8">&#160;&#160; <input id="mybutton"
						type="submit" value="Search" />
					</td>
				</tr>
			</table>
		</form>


		<c:choose>
			<c:when test="${not empty products}">
				<h3>Search Result</h3>
				<table>
					<tr class="headerTable">
						<td>&#160;</td>
						<td>Category</td>
						<td>Name</td>
						<td>Price</td>
						<td>Seller's Name</td>
						<td>Posting Date</td>
						<td>Buyers' Rating</td>
						<td>&#160;</td>
					</tr>
							<c:forEach var="product" items="${products}" varStatus="rowCounter">
								 <c:choose>
									<c:when test="${rowCounter.count % 2 == 0}">
										<c:set var="rowStyle" scope="page" value="odd" />
									</c:when>
									<c:otherwise>
										<c:set var="rowStyle" scope="page" value="even" />
									</c:otherwise>
								</c:choose>
								<tr class="{rowStyle}">
									<td>${rowCounter.count}</td>
									<td>${fn:escapeXml(product.category)}</td>
									<td><a href="/service/product/detail?id=${product.productId}">${fn:escapeXml(product.name)}</a></td>
									<td><fmt:formatNumber type="number" pattern="###,###.00" value="${product.price}" /></td>
									<td>${fn:escapeXml(product.ownerName)}</td>
									<td><fmt:formatDate type="date" value="${product.createdDate}"/></td>
									<td align="right">${product.rating}</td>
									<td>&#160;</td>
								</tr>
							</c:forEach>
				</table>
			</c:when>
			<c:otherwise>
				<h3>Search Result</h3>
				<p>No Product Found.</p>
			</c:otherwise>
		</c:choose>
	</div>
</body>
	</html>
</jsp:root>